In [3]:
import numpy as np
In [ ]:
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
%matplotlib inline
In [1]:
import plotly
from plotly import graph_objs as go
from plotly.offline import iplot, plot
from plotly.offline import init_notebook_mode
init_notebook_mode()
In [1]:
from pyth.HWS import hws_exp
In [372]:
from pyth.HWS.hws_exp import *

My Awesome PhD¶

This is my PhD

I did things:

  • code
  • graph
  • success!!

I did maths:

$$ \sum_{n=1}^{\infty}{n} = -\frac{1}{12} $$

and graphs:

In [8]:
trace = go.Scatter(
    x = np.random.randn(100), 
    y = np.random.randn(100), 
    mode='markers'
)

trace2 = go.Scatter(
    x = np.random.randn(100) + 4, 
    y = np.random.randn(100) + 4, 
    mode='markers'
)

iplot([trace, trace2])

viz_data¶

In [429]:
class viz_data:

    def __init__(self, data):
        '''

        Parameters
        ----------

        data : dictionary
            Output of load_data
            Dictionary for each file type
        '''

        self.data = data
        self.data_sig = data['data_sig']

        self.pref_oris = self.data['data']['pref_oris']
        self.cvs = self.data['data']['cvs']


        if 'hw_oris' not in self.data['data'].keys():
            self.hw_oris = np.arange(0, 90 + 15, 15)
        else:
            self.hw_oris = self.data['data']['hw_oris']

        self.plasma_cmap = mpl.cm.get_cmap('rainbow_r')


    def mean_pref_ori(self):

        pref_oris = self.pref_oris
        hw_oris = self.hw_oris

        circ_mean_pref_oris = [
            cs.mean(np.ones(pref_oris.shape[0]), pref_oris[:, hwo], single_angle=True)[0] 
            for hwo in range(pref_oris.shape[1])
        ]

#         with sns.plotting_context('poster'), sns.axes_style('whitegrid'):

        plt.plot(hw_oris, np.degrees(circ_mean_pref_oris), color='purple', 
                 linewidth=10, label='Mean')
#         plt.plot(hw_oris, np.degrees( np.percentile(pref_oris, 97.5, axis=0)), '--', 
#                  color='0.65', linewidth=2)
#         plt.plot(hw_oris, np.degrees( np.percentile(pref_oris, 2.5, axis=0)), '--', 
#                  color='0.65', linewidth=2)
        
        plt.fill_between(hw_oris, 
                         np.degrees( np.percentile(pref_oris, 2.5, axis=0)), 
                         np.degrees( np.percentile(pref_oris, 97.5, axis=0)),
                        color='purple', alpha = 0.25)
        
        plt.plot(hw_oris, hw_oris, '--', color='0.65', linewidth=5, label='Pref ori = HW Ori')

        plt.ylim(ymax=90*1.05)
        plt.yticks(np.arange(0, 90+10, 10))
        plt.xlabel('Spatial Convergence Orientation (Degs)')
        plt.ylabel('Preferred Orientation (Degs)')
        plt.title('Mean Preferred Orientation \n for Various Spatial Convergence Orientations')

#         plt.legend()

        sns.despine(offset=20)

        plt.savefig(self.data_sig + '_mean_pref_ori.svg')
        plt.savefig(self.data_sig + '_mean_pref_ori.pdf')

#         plt.clf()


    def mean_circ_var(self):

        hw_oris = self.hw_oris

        cvs = self.cvs

#         with sns.plotting_context('poster'), sns.axes_style('whitegrid'):

        plt.plot(hw_oris, np.mean(cvs, axis=0), color='purple', linewidth=10)
#         plt.plot(hw_oris, np.percentile(cvs, 97.5, axis=0), '--', color='0.65', linewidth=2)
#         plt.plot(hw_oris, np.percentile(cvs, 2.5, axis=0), '--', color='0.65', linewidth=2) 
        
        plt.fill_between(hw_oris, 
                  np.percentile(cvs, 2.5, axis=0), 
                  np.percentile(cvs, 97.5, axis=0),
                color='purple', alpha = 0.25)
        
        plt.xlabel('Spatial Convergence Orientation (Degs)')
        plt.ylabel('Circular Variance (0: Circular)')
        plt.title('Mean Circular Variance \nfor Various Spatial Convergence Orientations')
        sns.despine(offset=20)

        plt.savefig(self.data_sig + '_mean_circ_vars.svg')
        plt.savefig(self.data_sig + '_mean_circ_vars.pdf')

#         plt.clf()


    def pref_ori_circ_var(self):

        hw_oris = self.hw_oris
        pref_oris = self.pref_oris
        cvs = self.cvs

        plasma_cmap = self.plasma_cmap

#         with sns.plotting_context('poster'), sns.axes_style('white'):
        for hwo in range(hw_oris.size):

            plt.axvline(x=np.radians(hw_oris[hwo]), 
                        color = plasma_cmap(hwo/7.), linestyle='-', linewidth=3,
                        zorder=0)

            plt.plot(pref_oris[:,hwo], cvs[:,hwo], 'o', label='%s'%(hw_oris[hwo]), markersize=15,
                    color = plasma_cmap(hwo/7.),  alpha=0.2, markeredgecolor=None, markeredgewidth=1)



#         plt.legend(title='HW Ori')
        plt.xlim(xmax=np.pi*1.2 / 2.)
        plt.ylabel('Circular Variance (0: Circular)')
        plt.xlabel('Preferred Orientation (Degs)')
        plt.xticks(np.linspace(0, np.pi/2., 7, endpoint=True), np.linspace(0, 90, 7, endpoint=True).astype('int'));

        plt.title('Orientation Tuning for all Trials')
        sns.despine(offset=20)

        plt.savefig(self.data_sig + '_pref_ori_v_circ_var.svg')
        plt.savefig(self.data_sig + '_pref_ori_v_circ_var.pdf')


    def rf_locs(self, trial='rand', hw_ori_idx=0, save=False):

        fig = plt.figure()

        if trial=='rand':
            trial_idx = np.random.randint(0, high=self.pref_oris.shape[0])
            
        else:
            trial_idx = trial


        hw_ori = np.radians(self.hw_oris[hw_ori_idx])
        dists = self.data['data']['dists'][trial_idx, hw_ori_idx, :]
        
        n_inputs = dists.size

        x_locs = dists * np.cos(hw_ori)
        y_locs = dists * np.sin(hw_ori)

        ells = [
            mpl.patches.Ellipse(xy = [x_locs[i],y_locs[i]],
                               width=13, height=1.4*13,
                               angle=0.,
                               facecolor='none', edgecolor='k')
            for i in range(n_inputs)

        ]
        
        
        ax = plt.gca()
        
        for el in ells:
            ax.add_artist(el)
        plt.axis('square')
        plt.xlim((-20, 20))
        plt.ylim((-20, 20))
        
        plt.title('Trial: %s; HW_idx: %s'%(trial_idx, hw_ori_idx))
        
        if save:
            plt.savefig(self.data_sig + '_rf_locs.svg')
            plt.savefig(self.data_sig + '_rf_locs.pdf')
In [360]:
hws_exp.sns.set_style('white')
hws_exp.sns.set_context('poster', font_scale=1.5)
In [3]:
data = hws_exp.load_data('2017_12_01__22_24_n_inputs_30#data.npz')
In [106]:
np.linspace(30, 90, 3, endpoint=False)
Out[106]:
array([ 30.,  50.,  70.])
In [152]:
hw_idx = 5

hw_ori = data['data']['hw_oris'][hw_idx]

bins = np.r_[np.linspace(hw_ori, 90., 3, endpoint=False), 90.]

plt.hist(np.degrees(data['data']['pref_oris'][:, hw_idx]), bins=bins)

c, b = np.histogram(np.degrees(data['data']['pref_oris'][:, hw_idx]), bins=bins)

plt.title('HW_Ori: %s'%hw_ori)
Out[152]:
<matplotlib.text.Text at 0x113093550>
In [348]:
prgn_cmap = mpl.cm.get_cmap('PiYG_r')
In [190]:
prgn_cmap()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-190-d33a9e357d7c> in <module>()
----> 1 prgn_cmap()

TypeError: __call__() takes at least 2 arguments (1 given)

Scores¶

In [349]:
scores = np.zeros((6, 4))

cols = [prgn_cmap(0.12), prgn_cmap(0.333), prgn_cmap(0.666), prgn_cmap(0.87)]

for hw_idx in range(6):
    
    hw_ori = data['data']['hw_oris'][hw_idx]

    bins = np.r_[np.linspace(hw_ori, 90., 4, endpoint=False), 90.]

    plt.hist(np.degrees(data['data']['pref_oris'][:, hw_idx]), bins=bins)
    plt.title('HW_Ori: %s'%hw_ori)
    plt.show()

    c, b = np.histogram(np.degrees(data['data']['pref_oris'][:, hw_idx]), bins=bins)
    
    c_prob = c / c.sum().astype('float') * 100
    
    scores[hw_idx, :] = c_prob
    
#     sag_score = (c_prob[2] - c_prob[0]) * 100
#     hub_score = (c_prob[0] - c_prob[2]) * 100
    
#     s_score.append(c_prob[2])
    
#     hw_score.append(c_prob[0])
In [435]:
for i in range(4):
    plt.plot(data['data']['hw_oris'][:-1], scores[:,i], linewidth=12, color=cols[i]  )
    
plt.ylabel('Frequency (%)')
plt.xlabel('Spatial Convergence Orientation')

plt.title('Frequency of Determination of Both Mechanisms')
hws_exp.sns.despine(offset=20)
plt.savefig('scores_hw_ori.svg')
In [351]:
hw_idx = 1

hw_ori = data['data']['hw_oris'][hw_idx]

bins = np.r_[np.linspace(hw_ori, 90., 4, endpoint=False), 90.]

c, b = np.histogram(np.degrees(data['data']['pref_oris'][:, hw_idx]), bins=bins)
In [352]:
c / c.sum().astype('float')
Out[352]:
array([ 0.063,  0.09 ,  0.219,  0.628])
In [436]:
plt.bar(b[:-1], c/c.sum().astype('float')*100, color=cols, width=(b[1]-b[0]), align='edge')
plt.xlabel('Preferred Orientation (Degs)')
plt.ylabel('Frequency (%)')
plt.title('Which Mechanism is Determinative')

hws_exp.sns.despine(offset=20, trim=False)

plt.savefig('score_n_30.svg')

RF Locs¶

In [204]:
dv = viz_data(data)
In [212]:
dv.rf_locs(save=False)
In [69]:
    def rf_locs(data, trial='rand', hw_ori_idx=0, save=True):

        fig = plt.figure()

        if trial=='rand':
            trial_idx = np.random.randint(0, high=data['pref_oris'].shape[0])


        hw_ori = np.radians(data['hw_oris'][hw_ori_idx])
        dists = data['dists'][trial_idx, hw_ori_idx, :]
        
        n_inputs = dists.size

        x_locs = dists * np.cos(hw_ori)
        y_locs = dists * np.sin(hw_ori)

        ells = [
            mpl.patches.Ellipse(xy = [x_locs[i],y_locs[i]],
                               width=13, height=1.4*13,
                               angle=0.,
                               facecolor='none', edgecolor='k')
            for i in range(n_inputs)

        ]
        
        
        ax = plt.gca()
        
        for el in ells:
            ax.add_artist(el)
        plt.axis('equal')
        plt.xlim((-30, 30))
        plt.ylim((-30, 30))
        
        plt.title('Trial: %s; HW_idx: %s'%(trial_idx, hw_ori_idx))
        
        if save:
            plt.savefig('rf_locs.svg')
In [71]:
rf_locs(data['data'], hw_ori_idx=2, save=False)

make Data Viz¶

In [430]:
dv = viz_data(data)
In [431]:
dv.pref_ori_circ_var()
In [432]:
dv.mean_pref_ori()
In [433]:
dv.mean_circ_var()
In [ ]:
 
In [40]:
plt.hist(data['data']['dists'].flatten())
Out[40]:
(array([  3.30000000e+01,   1.72000000e+02,   1.35200000e+03,
          1.14990000e+04,   9.65680000e+04,   8.77160000e+04,
          1.10890000e+04,   1.37300000e+03,   1.75000000e+02,
          2.30000000e+01]),
 array([-30.68 , -24.531, -18.382, -12.233,  -6.084,   0.065,   6.214,
         12.363,  18.512,  24.661,  30.81 ]),
 <a list of 10 Patch objects>)
In [8]:
data['params']
Out[8]:
{'rf': {'cent_sd_hr': 0.1,
  'cent_sd_vt': 0.14,
  'mag_cent': 1.0,
  'mag_surr': 0.15,
  'ori': None,
  'rf_size': 51,
  'surr_sd_hr': 0.3,
  'surr_sd_vt': 0.3},
 'rf_layer': {'hws': 'rand',
  'hws_ori': 90,
  'hws_rand_size': 30,
  'resample_only': True,
  'rf_dist_factor': 1,
  'rf_dist_scale': 13,
  'rf_dists': array([ 0.  ,  0.01,  0.02,  0.03,  0.04,  0.05,  0.06,  0.07,  0.08,
          0.09,  0.1 ,  0.11,  0.12,  0.13,  0.14,  0.15,  0.16,  0.17,
          0.18,  0.19,  0.2 ,  0.21,  0.22,  0.23,  0.24,  0.25,  0.26,
          0.27,  0.28,  0.29,  0.3 ,  0.31,  0.32,  0.33,  0.34,  0.35,
          0.36,  0.37,  0.38,  0.39,  0.4 ,  0.41,  0.42,  0.43,  0.44,
          0.45,  0.46,  0.47,  0.48,  0.49,  0.5 ,  0.51,  0.52,  0.53,
          0.54,  0.55,  0.56,  0.57,  0.58,  0.59,  0.6 ,  0.61,  0.62,
          0.63,  0.64,  0.65,  0.66,  0.67,  0.68,  0.69,  0.7 ,  0.71,
          0.72,  0.73,  0.74,  0.75,  0.76,  0.77,  0.78,  0.79,  0.8 ,
          0.81,  0.82,  0.83,  0.84,  0.85,  0.86,  0.87,  0.88,  0.89,
          0.9 ,  0.91,  0.92,  0.93,  0.94,  0.95,  0.96,  0.97,  0.98,
          0.99,  1.  ,  1.01,  1.02,  1.03,  1.04,  1.05,  1.06,  1.07,
          1.08,  1.09,  1.1 ,  1.11,  1.12,  1.13,  1.14,  1.15,  1.16,
          1.17,  1.18,  1.19,  1.2 ,  1.21,  1.22,  1.23,  1.24,  1.25,
          1.26,  1.27,  1.28,  1.29,  1.3 ,  1.31,  1.32,  1.33,  1.34,
          1.35,  1.36,  1.37,  1.38,  1.39,  1.4 ,  1.41,  1.42,  1.43,
          1.44,  1.45,  1.46,  1.47,  1.48,  1.49,  1.5 ,  1.51,  1.52,
          1.53,  1.54,  1.55,  1.56,  1.57,  1.58,  1.59,  1.6 ,  1.61,
          1.62,  1.63,  1.64,  1.65,  1.66,  1.67,  1.68,  1.69,  1.7 ,
          1.71,  1.72,  1.73,  1.74,  1.75,  1.76,  1.77,  1.78,  1.79,
          1.8 ,  1.81,  1.82,  1.83,  1.84,  1.85,  1.86,  1.87,  1.88,
          1.89,  1.9 ,  1.91,  1.92,  1.93,  1.94,  1.95,  1.96,  1.97,
          1.98,  1.99,  2.  ,  2.01,  2.02,  2.03,  2.04,  2.05,  2.06,
          2.07,  2.08,  2.09,  2.1 ,  2.11,  2.12,  2.13,  2.14,  2.15,
          2.16,  2.17,  2.18,  2.19,  2.2 ,  2.21,  2.22,  2.23,  2.24,
          2.25,  2.26,  2.27,  2.28,  2.29,  2.3 ,  2.31,  2.32,  2.33,
          2.34,  2.35,  2.36,  2.37,  2.38,  2.39,  2.4 ,  2.41,  2.42,
          2.43,  2.44,  2.45,  2.46,  2.47,  2.48]),
  'rf_dists_prob': array([  4.32238181e-02,   4.13555254e-02,   3.95679874e-02,
           3.78577134e-02,   3.62213639e-02,   3.46557436e-02,
           3.31577953e-02,   3.17245939e-02,   3.03533408e-02,
           2.90413585e-02,   2.77860849e-02,   2.65850690e-02,
           2.54359655e-02,   2.43365305e-02,   2.32846173e-02,
           2.22781716e-02,   2.13152284e-02,   2.03939072e-02,
           1.95124089e-02,   1.86690123e-02,   1.78620704e-02,
           1.70900076e-02,   1.63513163e-02,   1.56445539e-02,
           1.49683405e-02,   1.43213556e-02,   1.37023358e-02,
           1.31100723e-02,   1.25434087e-02,   1.20012384e-02,
           1.14825028e-02,   1.09861888e-02,   1.05113274e-02,
           1.00569913e-02,   9.62229332e-03,   9.20638460e-03,
           8.80845302e-03,   8.42772153e-03,   8.06344668e-03,
           7.71491716e-03,   7.38145239e-03,   7.06240123e-03,
           6.75714065e-03,   6.46507457e-03,   6.18563269e-03,
           5.91826933e-03,   5.66246243e-03,   5.41771245e-03,
           5.18354149e-03,   4.95949228e-03,   4.74512731e-03,
           4.54002800e-03,   4.34379385e-03,   4.15604168e-03,
           3.97640486e-03,   3.80453262e-03,   3.64008934e-03,
           3.48275392e-03,   3.33221912e-03,   3.18819100e-03,
           3.05038832e-03,   2.91854199e-03,   2.79239455e-03,
           2.67169967e-03,   2.55622169e-03,   2.44573509e-03,
           2.34002414e-03,   2.23888241e-03,   2.14211240e-03,
           2.04952516e-03,   1.96093989e-03,   1.87618361e-03,
           1.79509080e-03,   1.71750314e-03,   1.64326910e-03,
           1.57224374e-03,   1.50428836e-03,   1.43927027e-03,
           1.37706250e-03,   1.31754359e-03,   1.26059730e-03,
           1.20611245e-03,   1.15398264e-03,   1.10410607e-03,
           1.05638536e-03,   1.01072732e-03,   9.67042783e-04,
           9.25246459e-04,   8.85256729e-04,   8.46995505e-04,
           8.10388075e-04,   7.75362955e-04,   7.41851752e-04,
           7.09789030e-04,   6.79112178e-04,   6.49761295e-04,
           6.21679067e-04,   5.94810659e-04,   5.69103603e-04,
           5.44507704e-04,   5.20974931e-04,   4.98459333e-04,
           4.76916943e-04,   4.56305697e-04,   4.36585346e-04,
           4.17717382e-04,   3.99664963e-04,   3.82392836e-04,
           3.65867276e-04,   3.50056013e-04,   3.34928172e-04,
           3.20454212e-04,   3.06605872e-04,   2.93356109e-04,
           2.80679050e-04,   2.68549942e-04,   2.56945098e-04,
           2.45841860e-04,   2.35218545e-04,   2.25054410e-04,
           2.15329607e-04,   2.06025147e-04,   1.97122860e-04,
           1.88605363e-04,   1.80456024e-04,   1.72658931e-04,
           1.65198857e-04,   1.58061235e-04,   1.51232129e-04,
           1.44698201e-04,   1.38446695e-04,   1.32465402e-04,
           1.26742644e-04,   1.21267244e-04,   1.16028511e-04,
           1.11016217e-04,   1.06220572e-04,   1.01632213e-04,
           9.72421804e-05,   9.30419013e-05,   8.90231741e-05,
           8.51781513e-05,   8.14993248e-05,   7.79795110e-05,
           7.46118368e-05,   7.13897261e-05,   6.83068870e-05,
           6.53572999e-05,   6.25352050e-05,   5.98350916e-05,
           5.72516872e-05,   5.47799472e-05,   5.24150452e-05,
           5.01523630e-05,   4.79874825e-05,   4.59161763e-05,
           4.39343996e-05,   4.20382828e-05,   4.02241233e-05,
           3.84883785e-05,   3.68276591e-05,   3.52387223e-05,
           3.37184653e-05,   3.22639195e-05,   3.08722446e-05,
           2.95407231e-05,   2.82667550e-05,   2.70478525e-05,
           2.58816356e-05,   2.47658270e-05,   2.36982478e-05,
           2.26768133e-05,   2.16995291e-05,   2.07644868e-05,
           1.98698606e-05,   1.90139034e-05,   1.81949439e-05,
           1.74113829e-05,   1.66616904e-05,   1.59444024e-05,
           1.52581182e-05,   1.46014978e-05,   1.39732591e-05,
           1.33721751e-05,   1.27970723e-05,   1.22468276e-05,
           1.17203665e-05,   1.12166610e-05,   1.07347276e-05,
           1.02736251e-05,   9.83245326e-06,   9.41035048e-06,
           9.00649257e-06,   8.62009092e-06,   8.25039099e-06,
           7.89667088e-06,   7.55823988e-06,   7.23443714e-06,
           6.92463037e-06,   6.62821461e-06,   6.34461105e-06,
           6.07326590e-06,   5.81364930e-06,   5.56525431e-06,
           5.32759588e-06,   5.10020994e-06,   4.88265247e-06,
           4.67449866e-06,   4.47534203e-06,   4.28479370e-06,
           4.10248158e-06,   3.92804967e-06,   3.76115737e-06,
           3.60147878e-06,   3.44870209e-06,   3.30252899e-06,
           3.16267404e-06,   3.02886414e-06,   2.90083801e-06,
           2.77834565e-06,   2.66114787e-06,   2.54901581e-06,
           2.44173052e-06,   2.33908251e-06,   2.24087133e-06,
           2.14690520e-06,   2.05700064e-06,   1.97098210e-06,
           1.88868160e-06,   1.80993843e-06,   1.73459884e-06,
           1.66251571e-06,   1.59354828e-06,   1.52756189e-06,
           1.46442767e-06,   1.40402235e-06,   1.34622798e-06,
           1.29093169e-06,   1.23802552e-06,   1.18740615e-06,
           1.13897474e-06,   1.09263672e-06,   1.04830160e-06,
           1.00588281e-06,   9.65297523e-07,   9.26466481e-07,
           8.89313863e-07,   8.53767120e-07,   8.19756841e-07]),
  'rf_layer_num': 10},
 'stim': {'freqs': array([  0.    ,   1.    ,   1.5625,   3.125 ,   6.25  ,  12.5   ,
          25.    ,  50.    ]),
  'img_size': 151,
  'num_t': 10,
  'oris': array([   0. ,   22.5,   45. ,   67.5,   90. ,  112.5,  135. ,  157.5])}}
In [ ]:
 

All Resp¶

In [260]:
plt.imshow(data['data']['all_resp'][648, 6, ...], cmap='gray')
Out[260]:
<matplotlib.image.AxesImage at 0x11d98f390>
In [262]:
data['data']['all_circ_stat'][648, 6, ...]
Out[262]:
array([[  1.57079633e+00,   1.57079633e+00,   1.41725473e-17],
       [  1.59617586e+00,   1.57079633e+00,   1.42178099e-02],
       [  1.55419816e+00,   9.39706126e-01,   2.72438593e-02],
       [  1.56280889e+00,   2.50377376e-01,   6.49394295e-02],
       [  1.58037202e+00,   9.80374585e-02,   1.67087862e-01],
       [  1.56677387e+00,   1.22200436e-01,   2.56372652e-01],
       [  1.59055539e+00,   1.57079633e+00,   3.20375359e-03],
       [  1.56725819e+00,   1.57079633e+00,   2.20776398e-03]])
In [279]:
plt.hist(data['data']['all_circ_stat'][:, 2, 5, 2].flatten())
Out[279]:
(array([   7.,   20.,   68.,  170.,  278.,  253.,  125.,   60.,   14.,    5.]),
 array([ 0.08573954,  0.09481326,  0.10388698,  0.11296071,  0.12203443,
         0.13110815,  0.14018188,  0.1492556 ,  0.15832932,  0.16740305,
         0.17647677]),
 <a list of 10 Patch objects>)
In [272]:
with hws_exp.sns.axes_style('dark'):
    cell.plot_rf()
    plt.savefig('kernel.svg')
In [ ]:
 

RF Prob Dist¶

In [437]:
from pyth.HWS import rfDistCalc as rfdc
In [440]:
opt = rfdc.make_rf_pdf()
In [441]:
opt
Out[441]:
{'opt_results': {'opt_n': [42], 'opt_x': [4.4185719645165822]},
 'opt_var': {'b': 4.4185719645165822}}
In [490]:
x, pdf = rfdc.jin_rf_dist(x = np.linspace(0, 2.5, 30), pdf=True)

x_pw, pdf_pw = rfdc.jin_rf_dist(x = np.linspace(0, 2.5, 30), b = 4.419, pdf=True)
pw_dists = rfdc.pdf_to_pair_wise_dist(x_pw, pdf_pw)

c, b = np.histogram(pw_dists, bins=x)

plt.plot(b[:-1], c/c.sum().astype('float'))
Out[490]:
[<matplotlib.lines.Line2D at 0x11e253490>]
In [498]:
plt.plot(x[:-1], pdf[:-1],color='orange', linewidth=10, alpha=0.75)
plt.plot(b[:-1], c/c.sum().astype('float'),color='purple', linewidth=10, alpha=0.75)
hws_exp.sns.despine(offset=20)

plt.yticks(np.linspace(0, 0.2, 5), np.array(np.linspace(0, 0.2, 5)*100).astype('int'));

plt.ylabel('Probability (%)')
plt.xlabel('LGN Receptive Field Separation (Rec Field Widths)')

plt.title('LGN Input Separation Probability Distribution')

plt.savefig('rf_pdf.svg')
In [523]:
plt.imshow(data['data']['all_resp'][0, 2, ...], origin='lower', cmap='gray')
plt.colorbar()
Out[523]:
<matplotlib.colorbar.Colorbar at 0x120f55810>
In [554]:
stim_oris = data['params']['stim']['oris']

so = np.r_[stim_oris, stim_oris+180, stim_oris[0]]

resp = data['data']['all_resp'][0, 2, 5, :] / np.max(data['data']['all_resp'][0, 2, 5, :]).astype('float')

r = np.r_[resp, resp, resp[0]]

plt.polar(np.radians(so), r, linewidth=10, color='purple')

plt.yticks(np.linspace(0, 1, 5), ['', '', '0.5', '', '1'])

plt.savefig('ori_tun_eg.svg')

Dispersion and RF modifications¶

In [240]:
from pyth.HWS import static_two_layer as sl
In [292]:
cell = sl.static_two_layer()
Generating Stimuli ... poor CPU and RAM
In [309]:
cell.make_rf(cent_sd_vt=0.12, mag_cent=1.2)
In [310]:
cell.make_rf_charact()
cell.make_rf_circ_stat()
In [311]:
cell.rf_circ_stat
Out[311]:
array([[  1.57079633e+00,   1.57079633e+00,   4.00304413e-17],
       [  1.94636444e+00,   1.57079633e+00,   6.48267522e-03],
       [  1.77930128e+00,   1.57079633e+00,   9.46568380e-03],
       [  1.71532298e+00,   1.57079633e+00,   1.80442418e-02],
       [  1.63109743e+00,   1.57079633e+00,   4.27856326e-02],
       [  1.57182322e+00,   1.57079633e+00,   1.05350440e-01],
       [  1.75116662e-02,   1.57079633e+00,   1.90333486e-04],
       [  7.94593396e-01,   1.57079633e+00,   1.07605453e-07]])
In [312]:
cell.plot_rf_charact()
In [512]:
cell.make_rf_layer(rf_layer_num=30)
In [513]:
cell.make_layer_two_resp()
In [514]:
cell.plot_layer_two_resp()
In [511]:
plt.imshow(cell.stim[0, 4, 3, ...], origin='lower')
hws_exp.sns.despine(bottom=True, left=True)
plt.savefig('stim_eg.svg')
In [ ]:
 
In [ ]:
 
In [ ]:
 

Broader Inputs¶

HW wins!!

In [556]:
!ls *#data*
2017_10_29__02_16_screen_test#data.npz
2017_10_29__20_02_CLI_mod_test2#data.npz
2017_12_01__22_24_n_inputs_30#data.npz
2017_12_02__12_00_n_inp_30_low_kernel_CV_0105#data.npz
In [557]:
brd_data = hws_exp.load_data('2017_12_02__12_00_n_inp_30_low_kernel_CV_0105#data.npz')
In [558]:
brd_data_dv = hws_exp.viz_data(brd_data)
In [559]:
brd_data_dv.pref_ori_circ_var()
In [562]:
brd_data_dv.mean_pref_ori()
<matplotlib.figure.Figure at 0x126873e90>
In [563]:
brd_data_dv.mean_circ_var()
<matplotlib.figure.Figure at 0x12300bd90>
In [ ]:
 
In [565]:
scores = np.zeros((6, 4))

cols = [prgn_cmap(0.12), prgn_cmap(0.333), prgn_cmap(0.666), prgn_cmap(0.87)]

for hw_idx in range(6):
    
    hw_ori = brd_data['data']['hw_oris'][hw_idx]

    bins = np.r_[np.linspace(hw_ori, 90., 4, endpoint=False), 90.]

    plt.hist(np.degrees(brd_data['data']['pref_oris'][:, hw_idx]), bins=bins)
    plt.title('HW_Ori: %s'%hw_ori)
    plt.show()

    c, b = np.histogram(np.degrees(brd_data['data']['pref_oris'][:, hw_idx]), bins=bins)
    
    c_prob = c / c.sum().astype('float') * 100
    
    scores[hw_idx, :] = c_prob
    
#     sag_score = (c_prob[2] - c_prob[0]) * 100
#     hub_score = (c_prob[0] - c_prob[2]) * 100
    
#     s_score.append(c_prob[2])
    
#     hw_score.append(c_prob[0])
In [ ]: